﻿using DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CToolsWin.DAL
{
    public class CrawlerDAL
    {
        private static DBHelpers db = DBFactorys.GetDBHelper();


        public int Insert(Dictionary<string, string> dicParam, string strTable, string strConn)
        {
            string sql = string.Format("INSERT INTO [{0}]({1}) VALUES({2}) ", strTable,
                string.Join(",", dicParam.Select(p => string.Format("[{0}]", p.Key))),
                string.Join(",", dicParam.Select(p => string.Format("@{0}", p.Key))));
            System.Data.Common.DbParameter[] ps = ADOHelper.ToArrSqlParam(dicParam);
            return db.ExecuteScalar<int>(strConn, System.Data.CommandType.Text, sql, ps);
        }
    }
}
